package com.example.mybatisplus.mytest;


import com.example.mybatisplus.mapper.Mapper;
import com.example.mybatisplus.mapper.StudentMapper;
import com.example.mybatisplus.mybatis.Student;
import com.example.mybatisplus.mybatis.User;


import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest
public class test {
    @Resource
    private Mapper mapper;

    @Resource
    StudentMapper studentMapper;

    @Test
    public void insert() {
        User user= new User();
        user.setName("张三");
        user.setAge(20);
        user.setEmail("123@qq.com");

        int a= mapper.insert(user);
        System.out.println(a);
    }
    @Test
    public void insertStudent(){
        Student student = new Student();
        student.setAge(12);
        student.setEmail("123@qq.com");
        student.setStatus(1);
        student.setName("小明");

        studentMapper.insert(student);

    }
    @Test
    public void insertStudent1(){
        Student student = new Student();
        student.setAge(12);
        student.setEmail("123@qq.com");
        student.setStatus(1);
        student.setName("小明");

        int i=studentMapper.insertStudent(student);
        System.out.println(i);

    }
    @Test
    public void selectStudentById(){

       Student s=studentMapper.selectStudentById(1);
        System.out.println(s);
    }

    @Test
    public void selectStudentByName(){

        List<Student> students = studentMapper.selectStudentByName("小明");
        System.out.println(students);
    }

}
